﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace CorporationWars
{
    [Serializable]
    public class BaseObject
    {
        [NonSerialized]
        public  Game1 Game;

        Random rnd = null;
        protected Random Rnd 
        {
            get
            {
                if(rnd == null)
                    rnd = new Random(DateTime.Now.Millisecond);
                return rnd;
            }
            set { rnd = value; }
        }
        private string id { get; set; }
        public string ID { get { return id; } }

        private static Dictionary<string, long> IDs { get; set; }

        public BaseObject(Game1 game)
        {
            Game = game;

            string thisType = this.GetType().Name;

            if (IDs == null)
                IDs = new Dictionary<string, long>();

            if (!IDs.Keys.Contains(thisType))
            {
                IDs.Add(thisType, 0);
            }

            IDs[thisType]++;
            id = string.Format("{0}{1:00}", thisType, IDs[thisType]);
        }        
    }
}
